//
//  TCM_TabBarController.swift
//  TCM_TradingProject
//
//  Created by 吕春海 on 2018/8/17.
//  Copyright © 2018年 lvchunhai. All rights reserved.
//

import UIKit
import CYLTabBarController

class TCM_TabBarController: CYLTabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
        
//        //去掉tabbar顶部黑线
//        let TabBarLine = UITabBar.appearance()
//        TabBarLine.shadowImage = UIImage.init(color: TCM_HexRGB(0xD6D6D6), size: CGSize(width: TCM_ScreenWidth, height: 0.5))
//        TabBarLine.backgroundImage = UIImage()
    }
    
    
    class func setup() -> TCM_TabBarController {
        let tabbar = TCM_TabBarController(viewControllers: self.createTabBarViewControllers(), tabBarItemsAttributes: self.configTabbar())
        return tabbar!
    }
        
    class func configTabbar() ->  [[String : String]] {
        let tabbarItem = UITabBarItem.appearance()
        tabbarItem.setTitleTextAttributes([.foregroundColor : TCM_HexRGB(0xAEAEAE)], for: UIControlState.normal)
        tabbarItem.setTitleTextAttributes([.foregroundColor : TCM_HexRGB(0x693C26)], for: UIControlState.selected)
        return [[CYLTabBarItemTitle : "首页",CYLTabBarItemImage : "TCM_Home_un",CYLTabBarItemSelectedImage : "TCM_Home_select"],
                [CYLTabBarItemTitle : "资讯",CYLTabBarItemImage : "TCM_Information_un",CYLTabBarItemSelectedImage : "TCM_Information_select"],
                [CYLTabBarItemTitle : "拍卖专场",CYLTabBarItemImage : "TCM_Auction_un",CYLTabBarItemSelectedImage : "TCM_Auction_select"],
                [CYLTabBarItemTitle : "我的",CYLTabBarItemImage : "TCM_Mine_un",CYLTabBarItemSelectedImage : "TCM_Mine_select"]]            
    }
        
    class func createTabBarViewControllers() -> (Array<UIViewController>){
        let homeNav : TCM_RootNavigationController = TCM_RootNavigationController(rootViewController: TCM_HomeViewController())
        let dataNav : TCM_RootNavigationController = TCM_RootNavigationController(rootViewController: TCM_InformationViewController())
        let hosNav : TCM_RootNavigationController = TCM_RootNavigationController(rootViewController: TCM_AuctionListViewController())
        let mineNav : TCM_RootNavigationController = TCM_RootNavigationController(rootViewController: TCM_MineViewController())
            
        return [homeNav,dataNav,hosNav,mineNav]
    }
        
    override func tabBarController(_ tabBarController: UITabBarController!, didSelect control: UIControl!) {
            
    }
        
    override var shouldAutorotate: Bool {
        return selectedViewController?.shouldAutorotate ?? false
    }
        
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return selectedViewController?.supportedInterfaceOrientations ?? .portrait
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
